package kgc.crm.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import kgc.crm.mapper.AreaMapper;
import kgc.crm.model.Area;
import kgc.crm.service.IAreaService;
import kgc.crm.util.EmptyChecker;
import kgc.crm.util.ResultUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
//地址查询
public class AreaServiceImpl implements IAreaService {
    @Autowired
    private AreaMapper areaMapper;
    @Override
    public ResponseEntity searchByParentId(Area area) {
        if (EmptyChecker.isEmpty(area)) {
            log.error("[地址查询]查询失败：参数为空");
            return ResultUtil.error("查询失败");
        }
        QueryWrapper<Area> wrapper = new QueryWrapper<>();
        wrapper.eq(Area.COL_PARENT_ID,area.getParentId());
        List<Area> list = areaMapper.selectList(wrapper);
        return ResultUtil.success(list);
    }
}
